package com.other;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Created by baiguantao on 2017/7/27.
 */
public class IntZeroUtils {
    public  static String  IntToStringAndFrontAddZero(Integer source,Integer zeronum){
        String xs=String.valueOf(source);
        Map<String,Object> rulelist=new LinkedHashMap<String,Object>();
        rulelist = getZeroStringMap(zeronum);
        String len=xs.length()+"";
        System.out.println(rulelist.get(len));
        xs = rulelist.get(len) + xs;
        System.out.println(xs);
        return xs;
    }
    public static Map<String,Object> getZeroStringMap(Integer zeronum){
        Map<String,Object> rulelist=new LinkedHashMap<String,Object>();
        int k=1;
        for (int i=zeronum;i>0;i--) {
            rulelist.put(k+"",getZeroString(i));
            k++;
        }
        return rulelist;
    }
    public static String[] getZeroStringArray(Integer zeronum){
        String [] ss =new String[]{};
        for (int i=zeronum;i>0;i--) {
            ss[i-1]=getZeroString(i);
        }
        return ss;
    }
    public static String getZeroString(Integer num){
        StringBuffer sb=new StringBuffer();
        for(int i=0;i<num;i++){
            sb.append("0");
        }
        return sb.toString();
    }

}
